//package com.example.lin.api;
//
//import com.alibaba.fastjson.JSON;
//import com.google.common.base.CaseFormat;
//import com.hoau.taurus.recharge.dao.FinAdjustFeeMappingDao;
//import com.hoau.zodiac.springboot.autoconfig.context.SpringApplicationContextHolder;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.util.*;
//
///**
// * @className: ApiTest
// * @description:
// * @author: Lin.Gu
// * @date: 2024/3/5
// */
//@RestController
//@RequestMapping("/test")
//public class ApiTest {
//
//    @Autowired
//    private xx xxdao;
//
//    <select id="getListCommon" parameterType="String" resultType="java.util.Map">
//    ${sql}
//    </select>
//
//    List<Map<String, Object>> getListCommon(@Param("sql") String sql);
//
//    @Autowired
//    private SpringApplicationContextHolder springApplicationContextHolder;
//
//
//    @GetMapping("/v1/sql")
//    public void test() throws Exception {
//        String sql = "SELECT %s from t_product_price_type currentTable where currentTable.project_code in (%s) limit 2";
//        String columnName = "currentTable.*";
//        String projectCodes = "'eBay', 'MC'";
//        String sqlStr = String.format(sql, columnName, projectCodes);
//        List<Map<String, Object>> listCommon = finAdjustFeeMappingDao.getListCommon(sqlStr);
//        System.out.println(listCommon.size());
//        System.out.println(JSON.toJSON(listCommon));
//
//
//        List<Map<String, Object>> commonList = new ArrayList<>();
//        listCommon.forEach(map -> {
//            Map<String, Object> b = new HashMap<>();
//            map.forEach((key, value) -> {
//                value = booleanToInteger(value);
//                if (key.startsWith("is_")) {
//                    String cleanedString = key.substring(3);
//                    b.put(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, cleanedString), value);
//                }
//                b.put(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, key), value);
//            });
//            commonList.add(b);
//        });
//        System.out.println(JSON.toJSON(commonList));
//
////        Map<String, Object> a = listCommon.get(0);
////        //Guava
////        Map<String, Object> b = new HashMap<>();
////        a.forEach((k, v) -> {
////            v = booleanToInteger(v);
////            if (k.startsWith("is_")) {
////                String cleanedString = k.substring(3);
////                b.put(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, cleanedString), v);
////            }
////            b.put(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, k), v);
////        });
//        //System.out.println(JSON.toJSON(b));
////
////        String dao = "com.hoau.taurus.common.dao.CommonProductPriceTypeDao";
////        String po = "com.hoau.taurus.shared.po.base.ProductPriceTypePO";
////        Example exampleCondition = new Example(Class.forName(po));
////        exampleCondition.createCriteria().andEqualTo("projectCode", "MC1");
////        List<?> tableData  = ((Mapper) this.springApplicationContextHolder.getContext()
////                .getBean(Class.forName(dao))).selectByExample(exampleCondition);
////
////        System.out.println(tableData);
////
//////        List<?> tableData = ((Mapper) this.springApplicationContextHolder.getContext().getBean(Class.forName(dao))).selectAll();
////        System.out.println(tableData.size());
////        //System.out.println(JSON.toJSON(tableData));
////
////        Object list = listCommon.size() > 0 ? listCommon : tableData;
////
////        System.out.println(JSON.toJSON(list));
//
//
//    }
//
//    public static void main(String[] args) {
//        String sql = "SELECT %s from t_product_price_type currentTable where currentTable.project_code in (%s)";
//        //String columnName = "UNIX_TIMESTAMP(max(currentTable.modify_time))";
//        String columnName = "currentTable.*";
//        String projectCodes = "'eBay', 'MC'";
//        String sqlStr = String.format(sql, columnName, projectCodes);
//        System.out.println(sqlStr);
//
//
//        String sql2 = "SELECT %s from t_product_price currentTable LEFT JOIN t_product_outer t2 on currentTable.product_outer_id = t2.product_outer_id \n" +
//                "and t2.project_code in(%s)";
//        String sqlStr2 = String.format(sql2, columnName, projectCodes);
//        System.out.println(sqlStr2);
//    }
//
//    public static Object booleanToInteger(Object obj) {
//        if (Objects.nonNull(obj)) {
//            if (obj instanceof Boolean) {
//                Boolean valueFlag = (Boolean) obj;
//                if (valueFlag) {
//                    return 1;
//                }
//                return 0;
//            }
//            return obj;
//        }
//        return obj;
//    }
//
//}
